<template>
  <div class="app-container">
    <div class="app-container-flex">
      <full-screen
        v-model="showDialog"
        :need-return="false"
        :full-model-header="false"
      >
        <div class="model-panel">
          <div class="model-panel-title">
            <p>对接系统信息</p>
          </div>
          <div class="model-panel-body">
            <!-- form -->
            <page-form
              class="paddingBox order-model-formBox flex_wrap_start_start"
              v-model:ref-obj="formInfo.ref"
              :disabled="formInfo.disabled"
              :data="formInfo.data"
              :field-list="formInfo.fieldList"
              :rules="formInfo.rules"
              :label-width="formInfo.labelWidth"
              @handleEvent="changClient"
            >
            </page-form>
          </div>
        </div>
        <div class="model-panel">
          <el-tabs v-model="activeName" @tab-change="handleClick">
            <el-tab-pane class="model-panel-title" label="物资信息" name="1">
              <div class="filter-wrapper">
                <NewPageFilter
                  v-model:query="productFilterInfo.query"
                  :query-more-json="false"
                  :filter-list="productFilterInfo.searchList"
                  :filter-btn="productFilterInfo.searchBtn"
                  :clear-type="productFilterInfo.clearType"
                >
                </NewPageFilter>
              </div>
              <div class="filter-wrapper">
                <NewPageFilter :filter-btn="productFilterInfo.btnList">
                  <template v-slot:filter-productRemove>
                    <el-button
                      :disabled="productTableInfo.selections.length === 0"
                      @click="productRemove"
                      >删除</el-button
                    >
                  </template>
                  <template v-slot:filter-productUpload>
                    <el-upload
                      :headers="productUploadInfo.headers"
                      :show-file-list="false"
                      :data="productUploadInfo.data"
                      :on-error="productUploadError"
                      :on-success="productImportOrders"
                      :before-upload="productBeforeUpload"
                      :action="
                        axios.defaults.baseURL +
                        '/tripartite/tripartiteSystemProduct/import/excel/' +
                        formInfo.data.tsSystemCode
                      "
                    >
                      <el-button>excel导入</el-button>
                    </el-upload>
                  </template>
                  <template v-slot:filter-productImport>
                    <el-button
                      :plain="true"
                      @click="
                        downloadTemplate('tripartite_system_product_import')
                      "
                      >下载导入模板</el-button
                    >
                  </template>
                </NewPageFilter>
              </div>
              <TableContainer
                v-if="activeName === '1'"
                :refresh="productTableInfo.refresh"
                :init-curpage="productTableInfo.initCurpage"
                :query="productFilterInfo.query"
                v-model:data="productTableInfo.data"
                :api="productTableInfo.api"
                :pager="true"
                :check-box="true"
                :tab-index="true"
                :field-list="productTableInfo.fieldList"
                :handle="productTableInfo.handle"
                @handleEvent="handleProductEvent"
              >
              </TableContainer>
            </el-tab-pane>
            <el-tab-pane class="model-panel-title" label="设备信息" name="2">
              <div class="filter-wrapper">
                <NewPageFilter
                  v-model:query="assetFilterInfo.query"
                  :query-more-json="false"
                  :filter-list="assetFilterInfo.searchList"
                  :filter-btn="assetFilterInfo.searchBtn"
                  :clear-type="assetFilterInfo.clearType"
                >
                </NewPageFilter>
              </div>
              <div class="filter-wrapper">
                <NewPageFilter :filter-btn="assetFilterInfo.btnList">
                  <template v-slot:filter-assetRemove>
                    <el-button
                      :disabled="assetTableInfo.selections.length === 0"
                      @click="assetRemove"
                      >删除</el-button
                    >
                  </template>
                  <template v-slot:filter-assetUpload>
                    <el-upload
                      :headers="assetUploadInfo.headers"
                      :show-file-list="false"
                      :data="assetUploadInfo.data"
                      :on-error="assetUploadError"
                      :on-success="assetImportOrders"
                      :before-upload="assetBeforeUpload"
                      :action="
                        axios.defaults.baseURL +
                        '/tripartite/tripartiteSystemDevice/import/excel/' +
                        formInfo.data.tsSystemCode
                      "
                    >
                      <el-button>excel导入</el-button>
                    </el-upload>
                  </template>
                  <template v-slot:filter-assetImport>
                    <el-button
                      :plain="true"
                      @click="
                        downloadTemplate('tripartite_system_device_import')
                      "
                      >下载导入模板</el-button
                    ></template
                  >
                </NewPageFilter>
              </div>
              <TableContainer
                v-if="activeName === '2'"
                :refresh="assetTableInfo.refresh"
                :init-curpage="assetTableInfo.initCurpage"
                :query="assetFilterInfo.query"
                v-model:data="assetTableInfo.data"
                :api="assetTableInfo.api"
                :pager="true"
                :check-box="true"
                :tab-index="true"
                :field-list="assetTableInfo.fieldList"
                :handle="assetTableInfo.handle"
                @handleEvent="handleAssetEvent"
              >
              </TableContainer>
            </el-tab-pane>
            <el-tab-pane class="model-panel-title" label="供应商信息" name="3">
              <div class="filter-wrapper">
                <NewPageFilter
                  v-model:query="supplierFilterInfo.query"
                  :query-more-json="false"
                  :filter-list="supplierFilterInfo.searchList"
                  :filter-btn="supplierFilterInfo.searchBtn"
                  :clear-type="supplierFilterInfo.clearType"
                >
                </NewPageFilter>
              </div>
              <div class="filter-wrapper">
                <NewPageFilter :filter-btn="supplierFilterInfo.btnList">
                  <template v-slot:filter-supplierRemove>
                    <el-button
                      :disabled="supplierTableInfo.selections.length === 0"
                      @click="supplierRemove"
                      >删除</el-button
                    >
                  </template>
                  <template v-slot:filter-supplierUpload>
                    <el-upload
                      :headers="supplierUploadInfo.headers"
                      :show-file-list="false"
                      :data="supplierUploadInfo.data"
                      :on-error="supplierUploadError"
                      :on-success="supplierImportOrders"
                      :before-upload="supplierBeforeUpload"
                      :action="
                        axios.defaults.baseURL +
                        '/tripartite/tripartiteSystemSupplier/import/excel/' +
                        formInfo.data.tsSystemCode
                      "
                    >
                      <el-button>excel导入</el-button>
                    </el-upload>
                  </template>
                  <template v-slot:filter-supplierImport>
                    <el-button
                      :plain="true"
                      @click="
                        downloadTemplate('tripartite_system_supplier_import')
                      "
                      >下载导入模板</el-button
                    ></template
                  >
                </NewPageFilter>
              </div>
              <TableContainer
                v-if="activeName === '3'"
                :refresh="supplierTableInfo.refresh"
                :init-curpage="supplierTableInfo.initCurpage"
                :query="supplierFilterInfo.query"
                v-model:data="supplierTableInfo.data"
                :api="supplierTableInfo.api"
                :pager="true"
                :check-box="true"
                :tab-index="true"
                :field-list="supplierTableInfo.fieldList"
                :handle="supplierTableInfo.handle"
                @handleEvent="handleSupplierEvent"
              >
              </TableContainer>
            </el-tab-pane>
            <el-tab-pane class="model-panel-title" label="人员信息" name="4">
              <div class="filter-wrapper">
                <NewPageFilter
                  v-model:query="userFilterInfo.query"
                  :query-more-json="false"
                  :filter-list="userFilterInfo.searchList"
                  :filter-btn="userFilterInfo.searchBtn"
                  :clear-type="userFilterInfo.clearType"
                >
                </NewPageFilter>
              </div>
              <div class="filter-wrapper">
                <NewPageFilter :filter-btn="userFilterInfo.btnList">
                  <template v-slot:filter-userRemove>
                    <el-button
                      :disabled="userTableInfo.selections.length === 0"
                      @click="userRemove"
                      >删除</el-button
                    >
                  </template>
                  <template v-slot:filter-userUpload>
                    <el-upload
                      :headers="userUploadInfo.headers"
                      :show-file-list="false"
                      :data="userUploadInfo.data"
                      :on-error="userUploadError"
                      :on-success="userImportOrders"
                      :before-upload="userBeforeUpload"
                      :action="
                        axios.defaults.baseURL +
                        '/tripartite/tripartiteSystemUser/import/excel/' +
                        formInfo.data.tsSystemCode
                      "
                    >
                      <el-button>excel导入</el-button>
                    </el-upload>
                  </template>
                  <template v-slot:filter-userImport>
                    <el-button
                      :plain="true"
                      @click="downloadTemplate('tripartite_system_user_import')"
                      >下载导入模板</el-button
                    >
                  </template>
                </NewPageFilter>
              </div>
              <TableContainer
                v-if="activeName === '4'"
                :refresh="userTableInfo.refresh"
                :init-curpage="userTableInfo.initCurpage"
                :query="userFilterInfo.query"
                v-model:data="userTableInfo.data"
                :api="userTableInfo.api"
                :pager="true"
                :check-box="true"
                :tab-index="true"
                :field-list="userTableInfo.fieldList"
                :handle="userTableInfo.handle"
                @handleEvent="handleUserEvent"
              >
              </TableContainer>
            </el-tab-pane>
            <el-tab-pane class="model-panel-title" label="部门信息" name="5">
              <div class="filter-wrapper">
                <NewPageFilter
                  v-model:query="deptFilterInfo.query"
                  :query-more-json="false"
                  :filter-list="deptFilterInfo.searchList"
                  :filter-btn="deptFilterInfo.searchBtn"
                  :clear-type="deptFilterInfo.clearType"
                >
                </NewPageFilter>
              </div>
              <div class="filter-wrapper">
                <NewPageFilter :filter-btn="deptFilterInfo.btnList">
                  <template v-slot:filter-deptRemove>
                    <el-button
                      :disabled="deptTableInfo.selections.length === 0"
                      @click="deptRemove"
                      >删除</el-button
                    >
                  </template>
                  <template v-slot:filter-deptUpload>
                    <el-upload
                      :headers="deptUploadInfo.headers"
                      :show-file-list="false"
                      :data="deptUploadInfo.data"
                      :on-error="deptUploadError"
                      :on-success="deptImportOrders"
                      :before-upload="deptBeforeUpload"
                      :action="
                        axios.defaults.baseURL +
                        '/tripartite/tripartiteSystemDept/import/excel/' +
                        formInfo.data.tsSystemCode
                      "
                    >
                      <el-button>excel导入</el-button>
                    </el-upload>
                  </template>
                  <template v-slot:filter-deptImport>
                    <el-button
                      :plain="true"
                      @click="downloadTemplate('tripartite_system_dept_import')"
                      >下载导入模板</el-button
                    >
                  </template>
                </NewPageFilter>
              </div>
              <TableContainer
                v-if="activeName === '5'"
                :refresh="deptTableInfo.refresh"
                :init-curpage="deptTableInfo.initCurpage"
                :query="deptFilterInfo.query"
                v-model:data="deptTableInfo.data"
                :api="deptTableInfo.api"
                :pager="true"
                :check-box="true"
                :tab-index="true"
                :field-list="deptTableInfo.fieldList"
                :handle="deptTableInfo.handle"
                @handleEvent="handleDeptEvent"
              >
              </TableContainer>
            </el-tab-pane>
            <el-tab-pane class="model-panel-title" label="仓库信息" name="6">
              <div class="filter-wrapper">
                <NewPageFilter
                  v-model:query="depotFilterInfo.query"
                  :query-more-json="false"
                  :filter-list="depotFilterInfo.searchList"
                  :filter-btn="depotFilterInfo.searchBtn"
                  :clear-type="depotFilterInfo.clearType"
                >
                </NewPageFilter>
              </div>
              <div class="filter-wrapper">
                <NewPageFilter :filter-btn="depotFilterInfo.btnList">
                  <template v-slot:filter-depotRemove>
                    <el-button
                      :disabled="depotTableInfo.selections.length === 0"
                      @click="depotRemove"
                      >删除</el-button
                    >
                  </template>
                  <template v-slot:filter-depotUpload>
                    <el-upload
                      :headers="depotUploadInfo.headers"
                      :show-file-list="false"
                      :data="depotUploadInfo.data"
                      :on-error="depotUploadError"
                      :on-success="depotImportOrders"
                      :before-upload="depotBeforeUpload"
                      :action="
                        axios.defaults.baseURL +
                        '/tripartite/tripartiteSystemDepot/import/excel/' +
                        formInfo.data.tsSystemCode
                      "
                    >
                      <el-button>excel导入</el-button>
                    </el-upload>
                  </template>
                  <template v-slot:filter-depotImport>
                    <el-button
                      :plain="true"
                      @click="
                        downloadTemplate('tripartite_system_depot_import')
                      "
                      >下载导入模板</el-button
                    >
                  </template>
                </NewPageFilter>
              </div>
              <TableContainer
                v-if="activeName === '6'"
                :refresh="depotTableInfo.refresh"
                :init-curpage="depotTableInfo.initCurpage"
                :query="depotFilterInfo.query"
                v-model:data="depotTableInfo.data"
                :api="depotTableInfo.api"
                :pager="true"
                :check-box="true"
                :tab-index="true"
                :field-list="depotTableInfo.fieldList"
                :handle="depotTableInfo.handle"
                @handleEvent="handleDepotEvent"
              >
              </TableContainer>
            </el-tab-pane>
            <el-tab-pane class="model-panel-title" label="项目信息" name="7">
              <div class="filter-wrapper">
                <NewPageFilter
                  v-model:query="projectFilterInfo.query"
                  :query-more-json="false"
                  :filter-list="projectFilterInfo.searchList"
                  :filter-btn="projectFilterInfo.searchBtn"
                  :clear-type="projectFilterInfo.clearType"
                >
                </NewPageFilter>
              </div>
              <div class="filter-wrapper">
                <NewPageFilter :filter-btn="projectFilterInfo.btnList">
                  <template v-slot:filter-projectRemove>
                    <el-button
                      :disabled="projectTableInfo.selections.length === 0"
                      @click="projectRemove"
                      >删除</el-button
                    >
                  </template>
                  <template v-slot:filter-projectUpload>
                    <el-upload
                      :headers="projectUploadInfo.headers"
                      :show-file-list="false"
                      :data="projectUploadInfo.data"
                      :on-error="projectUploadError"
                      :on-success="projectImportOrders"
                      :before-upload="projectBeforeUpload"
                      :action="
                        axios.defaults.baseURL +
                        '/tripartite/tripartiteSystemProject/import/excel/' +
                        formInfo.data.tsSystemCode
                      "
                    >
                      <el-button>excel导入</el-button>
                    </el-upload>
                  </template>
                  <template v-slot:filter-projectImport>
                    <el-button
                      :plain="true"
                      @click="
                        downloadTemplate('tripartite_system_project_import')
                      "
                      >下载导入模板</el-button
                    >
                  </template>
                </NewPageFilter>
              </div>
              <TableContainer
                v-if="activeName === '7'"
                :refresh="projectTableInfo.refresh"
                :init-curpage="projectTableInfo.initCurpage"
                :query="projectFilterInfo.query"
                v-model:data="projectTableInfo.data"
                :api="projectTableInfo.api"
                :pager="true"
                :check-box="true"
                :tab-index="true"
                :field-list="projectTableInfo.fieldList"
                :handle="projectTableInfo.handle"
                @handleEvent="handleProjectEvent"
              >
              </TableContainer>
            </el-tab-pane>
          </el-tabs>
        </div>
      </full-screen>
    </div>
    <page-dialog
      v-show="userDialogInfo.visible"
      :title="userDialogInfo.title"
      v-model:visible="userDialogInfo.visible"
      :width="userDialogInfo.width"
      :bt-loading="userDialogInfo.btLoading"
      :bt-list="userDialogInfo.btList"
      @reset="handleUserClose"
    >
      <page-form
        class="paddingBox order-model-formBox flex_wrap_start_start"
        v-model:ref-obj="userFormInfo.ref"
        :data="userFormInfo.data"
        :field-list="userFormInfo.fieldList"
        :rules="userFormInfo.rules"
        :label-width="userFormInfo.labelWidth"
      />
    </page-dialog>
    <page-dialog
      v-show="deptDialogInfo.visible"
      :title="deptDialogInfo.title"
      v-model:visible="deptDialogInfo.visible"
      :width="deptDialogInfo.width"
      :bt-loading="deptDialogInfo.btLoading"
      :bt-list="deptDialogInfo.btList"
      @reset="handleDeptClose"
    >
      <page-form
        class="paddingBox order-model-formBox flex_wrap_start_start"
        v-model:ref-obj="deptFormInfo.ref"
        :data="deptFormInfo.data"
        :field-list="deptFormInfo.fieldList"
        :rules="deptFormInfo.rules"
        :label-width="deptFormInfo.labelWidth"
      />
    </page-dialog>
    <page-dialog
      v-show="dialogInfo.visible"
      :title="dialogInfo.title"
      v-model:visible="dialogInfo.visible"
      :width="dialogInfo.width"
      :bt-loading="dialogInfo.btLoading"
      :bt-list="dialogInfo.btList"
      @reset="handleUserClose"
    >
      <page-form
        class="paddingBox order-model-formBox flex_wrap_start_start"
        v-model:ref-obj="dialogInfo.formInfo.ref"
        :data="dialogInfo.formInfo.data"
        :field-list="dialogInfo.formInfo[`${dialogInfo.type}FieldList`]"
        :rules="dialogInfo.formInfo[`${dialogInfo.type}Rules`]"
        :label-width="dialogInfo.formInfo.labelWidth"
      />
    </page-dialog>
  </div>
</template>

<script setup name="informationSyncManage">
import { ElLoading } from 'element-plus'
import axios from 'axios'
import {
  getTripartiteSystemDeptPage,
  getTripartiteSystemUserPage,
  getTripartiteSystemUserPullData,
  deleteTripartiteSystemUser,
  getTripartiteSystemUserById,
  createdTripartiteSystemUser,
  updateTripartiteSystemUser,
  getTripartiteSystemDeptPullData,
  deleteTripartiteSystemDept,
  getTripartiteSystemDeptById,
  createdTripartiteSystemDept,
  updateTripartiteSystemDept,
  getTripartiteSystemProductPage,
  deleteTripartiteSystemProduct,
  saveTripartiteSystemProduct,
  updateTripartiteSystemProduct,
  getTripartiteSystemProductPullData,
  saveTripartiteSystemSupplier,
  getTripartiteSystemSupplierPage,
  deleteTripartiteSystemSupplier,
  updateTripartiteSystemSupplier,
  getTripartiteSystemSupplierPullData,
  saveTripartiteSystemDevice,
  getTripartiteSystemDevicePage,
  deleteTripartiteSystemDevice,
  updateTripartiteSystemDevice,
  getTripartiteSystemDevicePullData,
  saveTripartiteSystemProject,
  getTripartiteSystemProjectPage,
  deleteTripartiteSystemProject,
  updateTripartiteSystemProject,
  getTripartiteSystemProjectPullData,
  saveTripartiteSystemDepot,
  getTripartiteSystemDepotPage,
  deleteTripartiteSystemDepot,
  updateTripartiteSystemDepot,
  getTripartiteSystemDepotPullData,
} from '@/api/tripartite'
import { exportTemplateExcel } from '@/api/pub'
const { proxy } = getCurrentInstance()

const showDialog = ref(true)
const activeName = ref('1') //1物质信息，2资产信息，3供应商信息，4人员信息，5部门信息，6仓储信息
const formInfo = ref({
  ref: null,
  options: [],
  data: {
    tsSystemCode: 'SLIP',
  },
  fieldList: [
    {
      label: '对接系统',
      value: 'tsSystemCode',
      type: 'select-model',
      code: 'client_id',
    },
  ],
  labelWidth: '120px',
})
const userTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: undefined,
  data: [],
  selections: [],
  fieldList: [
    { label: '工号', value: 'tsUserName' },
    { label: '名称', value: 'tsName' },
    { label: '部门', value: 'tsDeptName' },
    { label: '性别', value: 'tsSexValue' },
    { label: '保留1', value: 'reserved1' },
    { label: '保留2', value: 'reserved2' },
    { label: '保留3', value: 'reserved3' },
    { label: '保留4', value: 'reserved4' },
    { label: '保留5', value: 'reserved5' },
    { label: '是否对照', value: 'isCompareValue' },
    { label: '对照时间', value: 'compareTime' },
    { label: '创建人', value: 'createUserName' },
    { label: '创建时间', value: 'createTime' },
  ],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '90',
    btList: [
      {
        label: '删除',
        event: userRemove,
        popconfirmText: '删除后将改变数据,是否继续？',
        show: proxy.$permission('informationSyncManage:userDel'),
      },
      {
        label: '修改',
        event: userUpdate,
        show: proxy.$permission('informationSyncManage:userUpdate'),
        ifRender: function (row) {
          return row.dataSource !== 3
        },
      },
    ],
  },
})
const userFilterInfo = ref({
  clearType: true,
  query: {
    sort: 'create_time desc',
  },
  searchList: [
    {
      componentType: 'input',
      event: userSearch,
      hidden: true,
      label: '工号',
      show: true,
      value: 'tsUserNameLike',
    },
    {
      componentType: 'input',
      event: userSearch,
      hidden: true,
      label: '名称',
      show: true,
      value: 'tsNameLike',
    },
    {
      label: '部门',
      value: 'tsDeptNameLike',
      event: userSearch,
      componentType: 'input',
      show: true,
      hidden: true,
    },
    {
      label: '性别',
      value: 'tsSexLike',
      event: userSearch,
      componentType: 'select-model',
      code: 'sex',
      show: true,
      hidden: true,
    },
    {
      label: '是否对照',
      value: 'isCompare',
      componentType: 'select-model',
      code: 'yes_or_no',
      event: userSearch,
      show: true,
      hidden: true,
    },
  ],
  searchBtn: [
    { type: 'button', label: '搜索', event: userSearch },
    { type: 'button', label: '重置', event: userClearSearch },
  ],
  btnList: [
    {
      type: 'button',
      label: '新增',
      event: userCreate,
      show: proxy.$permission('informationSyncManage:userAdd'),
    },
    {
      value: 'userRemove',
      label: '删除',
      type: 'slot',
      show: proxy.$permission('informationSyncManage:userDel'),
    },
    {
      type: 'slot',
      value: 'userImport',
      show: proxy.$permission('informationSyncManage:userImport'),
    },
    {
      type: 'slot',
      value: 'userUpload',
      show: proxy.$permission('informationSyncManage:userUpload'),
    },
    {
      type: 'button',
      label: '拉取最新数据',
      event: getUserNewList,
      show: proxy.$permission('informationSyncManage:userPullData'),
    },
  ],
})
const userDialogInfo = ref({
  visible: false,
  title: '新增数据',
  btLoading: false,
  type: '',
  msg: '',
  width: '400px',
  flag: true,
  btList: [
    { label: '取消', event: handleUserClose, show: true },
    {
      label: '保存',
      type: 'primary',
      event: checkUserConfirm,
      show: true,
    },
  ],
})
const userFormInfo = ref({
  ref: null,
  data: {
    dataSource: 1,
  },
  fieldList: [
    {
      label: '工号',
      value: 'tsUserName',
      type: 'input',
      disabled: false,
    },
    { label: '名称', value: 'tsName', type: 'input' },
    { label: '部门', value: 'tsDeptName', type: 'input' },
    { label: '性别', value: 'tsSex', type: 'select-model', code: 'sex' },
    { label: '保留1', value: 'reserved1', type: 'input' },
    { label: '保留2', value: 'reserved2', type: 'input' },
    { label: '保留3', value: 'reserved3', type: 'input' },
    { label: '保留4', value: 'reserved4', type: 'input' },
    { label: '保留5', value: 'reserved5', type: 'input' },
  ],
  rules: {
    tsUserName: [{ required: true, message: '请输入工号', trigger: 'blur' }],
    tsName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
    tsDeptName: [{ required: true, message: '请输入部门', trigger: 'blur' }],
  },
  labelWidth: '120px',
})
const userUploadInfo = ref({
  headers: {
    Authorization: proxy.$store.state.user.token,
  },
  loading: {},
  data: {},
})
const productUploadInfo = ref({
  headers: {
    Authorization: proxy.$store.state.user.token,
  },
  loading: {},
  data: {},
})
const assetUploadInfo = ref({
  headers: {
    Authorization: proxy.$store.state.user.token,
  },
  loading: {},
  data: {},
})
const supplierUploadInfo = ref({
  headers: {
    Authorization: proxy.$store.state.user.token,
  },
  loading: {},
  data: {},
})
const deptTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: undefined,
  data: [],
  selections: [],
  fieldList: [
    { label: '编码', value: 'tsCode' },
    { label: '名称', value: 'tsName' },
    { label: '上级部门', value: 'tsUpName' },
    { label: '保留1', value: 'reserved1' },
    { label: '保留2', value: 'reserved2' },
    { label: '保留3', value: 'reserved3' },
    { label: '保留4', value: 'reserved4' },
    { label: '保留5', value: 'reserved5' },
    { label: '是否对照', value: 'isCompareValue' },
    { label: '对照时间', value: 'compareTime' },
    { label: '创建人', value: 'createUserName' },
    { label: '创建时间', value: 'createTime' },
  ],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '90',
    btList: [
      {
        label: '删除',
        event: deptRemove,
        popconfirmText: '删除后将改变数据,是否继续？',
        show: proxy.$permission('informationSyncManage:deptDel'),
      },
      {
        label: '修改',
        event: deptUpdate,
        show: proxy.$permission('informationSyncManage:deptUpdate'),
        ifRender: function (row) {
          return row.dataSource !== 3
        },
      },
    ],
  },
})
const deptFilterInfo = ref({
  clearType: true,
  query: {
    sort: 'create_time desc',
  },
  searchList: [
    {
      componentType: 'input',
      event: deptSearch,
      hidden: true,
      label: '编码',
      show: true,
      value: 'tsCodeLike',
    },
    {
      componentType: 'input',
      event: deptSearch,
      hidden: true,
      label: '名称',
      show: true,
      value: 'tsNameLike',
    },
    {
      label: '上级部门',
      value: 'tsUpNameLike',
      componentType: 'input',
      event: deptSearch,
      show: true,
      hidden: true,
    },
    {
      label: '是否对照',
      value: 'isCompare',
      componentType: 'select-model',
      code: 'yes_or_no',
      event: deptSearch,
      show: true,
      hidden: true,
    },
  ],
  searchBtn: [
    { type: 'button', label: '搜索', event: deptSearch },
    { type: 'button', label: '重置', event: deptClearSearch },
  ],
  btnList: [
    {
      type: 'button',
      label: '新增',
      event: deptCreate,
      show: proxy.$permission('informationSyncManage:deptAdd'),
    },
    {
      value: 'deptRemove',
      label: '删除',
      type: 'slot',
      show: proxy.$permission('informationSyncManage:deptDel'),
    },
    {
      type: 'slot',
      value: 'deptImport',
      show: proxy.$permission('informationSyncManage:deptImport'),
    },
    {
      type: 'slot',
      value: 'deptUpload',
      show: proxy.$permission('informationSyncManage:deptUpload'),
    },
    {
      type: 'button',
      label: '拉取最新数据',
      event: getDeptNewList,
      show: proxy.$permission('informationSyncManage:deptPullData'),
    },
  ],
})
const deptDialogInfo = ref({
  visible: false,
  title: '新增数据',
  btLoading: false,
  type: '',
  msg: '',
  width: '400px',
  flag: true,
  btList: [
    { label: '取消', event: handleDeptClose, show: true },
    {
      label: '保存',
      type: 'primary',
      event: checkDeptConfirm,
      show: true,
    },
  ],
})
const deptFormInfo = ref({
  ref: null,
  data: {
    dataSource: 1,
  },
  fieldList: [
    { label: '名称', value: 'tsName', type: 'input' },
    { label: '编码', value: 'tsCode', type: 'input', disabled: false },
    { label: '上级部门', value: 'tsUpName', type: 'input' },
    { label: '保留1', value: 'reserved1', type: 'input' },
    { label: '保留2', value: 'reserved2', type: 'input' },
    { label: '保留3', value: 'reserved3', type: 'input' },
    { label: '保留4', value: 'reserved4', type: 'input' },
    { label: '保留5', value: 'reserved5', type: 'input' },
  ],
  rules: {
    tsUserName: [{ required: true, message: '请输入工号', trigger: 'blur' }],
    tsName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
    tsCode: [{ required: true, message: '请输入编码', trigger: 'blur' }],
  },
  labelWidth: '120px',
})
const deptUploadInfo = ref({
  headers: {
    Authorization: proxy.$store.state.user.token,
  },
  loading: {},
  data: {
    // supplierId: '',
  },
})
const projectUploadInfo = ref({
  headers: {
    Authorization: proxy.$store.state.user.token,
  },
  loading: {},
  data: {
    // supplierId: '',
  },
})
const depotUploadInfo = ref({
  headers: {
    Authorization: proxy.$store.state.user.token,
  },
  loading: {},
  data: {
    // supplierId: '',
  },
})
const dialogInfo = ref({
  visible: false,
  title: '新增数据',
  btLoading: false,
  type: 'product',
  msg: '',
  width: '30%',
  flag: true,
  btList: [
    { label: '取消', event: dialogClose, show: true },
    {
      label: '保存',
      type: 'primary',
      event: dialogSave,
      show: true,
    },
  ],
  formInfo: {
    ref: null,
    data: {},
    productFieldList: [
      {
        label: '编码',
        value: 'tsProductCode',
        type: 'input',
      },
      {
        label: '名称',
        value: 'tsCommonName',
        type: 'input',
      },
      { label: '型号', value: 'tsStandard', type: 'input' },
      { label: '厂家', value: 'tsBrandName', type: 'input' },
      { label: '单位', value: 'tsUnitName', type: 'input' },
      { label: '保留1', value: 'reserved1', type: 'input' },
      { label: '保留2', value: 'reserved2', type: 'input' },
      { label: '保留3', value: 'reserved3', type: 'input' },
      { label: '保留4', value: 'reserved4', type: 'input' },
      { label: '保留5', value: 'reserved5', type: 'input' },
    ],
    productRules: {
      tsProductCode: [
        { required: true, message: '请输入编码', trigger: 'blur' },
      ],
      tsCommonName: [
        { required: true, message: '请输入名称', trigger: 'blur' },
      ],
    },
    assetFieldList: [
      { label: '编码', value: 'tsCode', type: 'input' },
      { label: '名称', value: 'tsName', type: 'input' },
      { label: '型号', value: 'tsStandard', type: 'input' },
      { label: '厂家', value: 'tsFactory', type: 'input' },
      { label: '使用部门', value: 'tsUseDeptName', type: 'input' },
      { label: '仓库', value: 'tsDepotName', type: 'input' },
      { label: '位置', value: 'tsLocation', type: 'input' },
      { label: '保留1', value: 'reserved1', type: 'input' },
      { label: '保留2', value: 'reserved2', type: 'input' },
      { label: '保留3', value: 'reserved3', type: 'input' },
      { label: '保留4', value: 'reserved4', type: 'input' },
      { label: '保留5', value: 'reserved5', type: 'input' },
    ],
    assetRules: {
      tsCode: [{ required: true, message: '请输入编码', trigger: 'blur' }],
      tsName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
    },
    supplierFieldList: [
      { label: '编码', value: 'tsCode', type: 'input' },
      { label: '名称', value: 'tsName', type: 'input' },
      {
        label: '社会信用代码',
        value: 'tsUniformSocialCreditCode',
        type: 'input',
      },
      { label: '保留1', value: 'reserved1', type: 'input' },
      { label: '保留2', value: 'reserved2', type: 'input' },
      { label: '保留3', value: 'reserved3', type: 'input' },
      { label: '保留4', value: 'reserved4', type: 'input' },
      { label: '保留5', value: 'reserved5', type: 'input' },
    ],
    supplierRules: {
      tsCode: [{ required: true, message: '请输入编码', trigger: 'blur' }],
      tsName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
    },
    depotFieldList: [
      { label: '编码', value: 'tsCode', type: 'input' },
      { label: '名称', value: 'tsName', type: 'input' },
      { label: '保留1', value: 'reserved1', type: 'input' },
      { label: '保留2', value: 'reserved2', type: 'input' },
      { label: '保留3', value: 'reserved3', type: 'input' },
      { label: '保留4', value: 'reserved4', type: 'input' },
      { label: '保留5', value: 'reserved5', type: 'input' },
    ],
    depotRules: {
      tsCode: [{ required: true, message: '请输入编码', trigger: 'blur' }],
      tsName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
    },
    projectFieldList: [
      { label: '项目编码', value: 'tsProjectCode', type: 'input' },
      { label: '项目名称', value: 'tsProjectName', type: 'input' },
      { label: '单价', value: 'tsPrice', type: 'number', precision: proxy.$store.state.permission.systemConfig.price_precision },
      { label: '保留1', value: 'reserved1', type: 'input' },
      { label: '保留2', value: 'reserved2', type: 'input' },
      { label: '保留3', value: 'reserved3', type: 'input' },
      { label: '保留4', value: 'reserved4', type: 'input' },
      { label: '保留5', value: 'reserved5', type: 'input' },
    ],
    projectRules: {
      tsProjectCode: [
        { required: true, message: '请输入编码', trigger: 'blur' },
      ],
      tsProjectName: [
        { required: true, message: '请输入名称', trigger: 'blur' },
      ],
    },
    labelWidth: '120px',
  },
})
//物资信息
const productFilterInfo = ref({
  clearType: true,
  query: {
    sort: 'create_time desc',
  },
  searchList: [
    {
      componentType: 'input',
      event: productSearch,
      hidden: true,
      label: '编码',
      show: true,
      value: 'tsProductCodeLike',
    },
    {
      componentType: 'input',
      event: productSearch,
      hidden: true,
      label: '名称',
      show: true,
      value: 'tsCommonNameLike',
    },
    {
      componentType: 'input',
      event: productSearch,
      hidden: true,
      label: '厂家',
      show: true,
      value: 'tsBrandNameLike',
    },
    {
      componentType: 'input',
      event: productSearch,
      hidden: true,
      label: '保留字段1',
      show: true,
      value: 'reserved1',
    },
    // 如果 对接系统是 四川省采平台 保留2 搜索为字典 其他为输入框
    {
      label: '保留字段2',
      value: 'reserved2',
      componentType: 'input',
      event: productSearch,
      hidden: true,
      show: true,
    },
    {
      componentType: 'select-model',
      label: '数据来源',
      value: 'dataSourceMult',
      code: 'data_source',
      multiple: true,
      event: productSearch,
    },
    {
      label: '是否对照',
      value: 'isCompare',
      componentType: 'select-model',
      code: 'yes_or_no',
      event: productSearch,
      show: true,
      hidden: true,
    },
  ],
  searchBtn: [
    { type: 'button', label: '搜索', event: productSearch },
    { type: 'button', label: '重置', event: productClearSearch },
  ],
  btnList: [
    {
      type: 'button',
      label: '新增',
      event: openProductDialog,
      show: proxy.$permission('informationSyncManage:productAdd'),
    },
    {
      value: 'productRemove',
      label: '删除',
      type: 'slot',
      show: proxy.$permission('informationSyncManage:productDel'),
    },
    {
      type: 'slot',
      value: 'productImport',
      show: proxy.$permission('informationSyncManage:productImport'),
    },
    {
      type: 'slot',
      value: 'productUpload',
      show: proxy.$permission('informationSyncManage:productUpload'),
    },
    {
      type: 'button',
      label: '拉取最新数据',
      event: getProductNewList,
      show: proxy.$permission('informationSyncManage:productPullData'),
    },
  ],
})
const productTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: undefined,
  data: [],
  selections: [],
  fieldList: [
    { label: '编码', value: 'tsProductCode' },
    { label: '名称', value: 'tsCommonName' },
    { label: '型号', value: 'tsStandard' },
    { label: '厂家', value: 'tsBrandName' },
    { label: '单位', value: 'tsUnitName' },
    { label: '保留1', value: 'reserved1' },
    { label: '保留2', value: 'reserved2' },
    { label: '保留3', value: 'reserved3' },
    { label: '保留4', value: 'reserved4' },
    { label: '保留5', value: 'reserved5' },
    { label: '数据来源', value: 'dataSourceValue' },
    { label: '是否对照', value: 'isCompareValue' },
    { label: '最新对照时间', value: 'compareTime' },
    { label: '创建人', value: 'createUserName' },
    { label: '创建时间', value: 'createTime' },
  ],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '90',
    btList: [
      {
        label: '删除',
        event: productRemove,
        popconfirmText: '删除后将改变数据,是否继续？',
        show: proxy.$permission('informationSyncManage:productDel'),
      },
      {
        label: '修改',
        event: productUpdate,
        show: proxy.$permission('informationSyncManage:productUpdate'),
        ifRender: function (row) {
          return row.dataSource !== 3
        },
      },
    ],
  },
})

//设备信息
const assetFilterInfo = ref({
  clearType: true,
  query: {
    sort: 'create_time desc',
  },
  searchList: [
    {
      componentType: 'input',
      event: assetSearch,
      hidden: true,
      label: '编码',
      show: true,
      value: 'tsCodeLike',
    },
    {
      componentType: 'input',
      event: assetSearch,
      hidden: true,
      label: '名称',
      show: true,
      value: 'tsNameLike',
    },
    {
      componentType: 'input',
      event: assetSearch,
      hidden: true,
      label: '型号',
      show: true,
      value: 'tsStandardLike',
    },
    {
      componentType: 'input',
      event: assetSearch,
      hidden: true,
      label: '厂家',
      show: true,
      value: 'tsFactoryLike',
    },
    {
      componentType: 'input',
      event: assetSearch,
      hidden: true,
      label: '使用部门',
      show: true,
      value: 'tsUseDeptNameLike',
    },
    {
      componentType: 'input',
      event: assetSearch,
      hidden: true,
      label: '仓库',
      show: true,
      value: 'tsDepotNameLike',
    },
    {
      componentType: 'input',
      event: assetSearch,
      hidden: true,
      label: '位置',
      show: true,
      value: 'tsLocationLike',
    },
    {
      componentType: 'select-model',
      label: '数据来源',
      value: 'dataSourceMult',
      code: 'data_source',
      multiple: true,
      event: assetSearch,
    },
    {
      label: '是否对照',
      value: 'isCompare',
      componentType: 'select-model',
      code: 'yes_or_no',
      event: assetSearch,
      show: true,
      hidden: true,
    },
  ],
  searchBtn: [
    { type: 'button', label: '搜索', event: assetSearch },
    { type: 'button', label: '重置', event: assetClearSearch },
  ],
  btnList: [
    {
      type: 'button',
      label: '新增',
      event: openAssetDialog,
      show: proxy.$permission('informationSyncManage:assetAdd'),
    },
    {
      value: 'assetRemove',
      label: '删除',
      type: 'slot',
      show: proxy.$permission('informationSyncManage:assetDel'),
    },
    {
      type: 'slot',
      value: 'assetImport',
      show: proxy.$permission('informationSyncManage:assetImport'),
    },
    {
      type: 'slot',
      value: 'assetUpload',
      show: proxy.$permission('informationSyncManage:assetUpload'),
    },
    {
      type: 'button',
      label: '拉取最新数据',
      event: getAssetNewList,
      show: proxy.$permission('informationSyncManage:assetPullData'),
    },
  ],
})
const assetTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: undefined,
  data: [],
  selections: [],
  fieldList: [
    { label: '编码', value: 'tsCode' },
    { label: '名称', value: 'tsName' },
    { label: '型号', value: 'tsStandard' },
    { label: '厂家', value: 'tsFactory' },
    { label: '使用部门', value: 'tsUseDeptName' },
    { label: '仓库', value: 'tsDepotName' },
    { label: '位置', value: 'tsLocation' },
    { label: '保留1', value: 'reserved1' },
    { label: '保留2', value: 'reserved2' },
    { label: '保留3', value: 'reserved3' },
    { label: '保留4', value: 'reserved4' },
    { label: '保留5', value: 'reserved5' },
    { label: '数据来源', value: 'dataSourceValue' },
    { label: '是否对照', value: 'isCompareValue' },
    { label: '最新对照时间', value: 'compareTime' },
    { label: '创建人', value: 'createUserName' },
    { label: '创建时间', value: 'createTime' },
  ],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '90',
    btList: [
      {
        label: '删除',
        event: assetRemove,
        popconfirmText: '删除后将改变数据,是否继续？',
        show: proxy.$permission('informationSyncManage:assetDel'),
      },
      {
        label: '修改',
        event: assetUpdate,
        show: proxy.$permission('informationSyncManage:assetUpdate'),
        ifRender: function (row) {
          return row.dataSource !== 3
        },
      },
    ],
  },
})
//供应商信息
const supplierFilterInfo = ref({
  clearType: true,
  query: {
    sort: 'create_time desc',
  },
  searchList: [
    {
      componentType: 'input',
      event: supplierSearch,
      hidden: true,
      label: '编码',
      show: true,
      value: 'tsCodeLike',
    },
    {
      componentType: 'input',
      event: supplierSearch,
      hidden: true,
      label: '名称',
      show: true,
      value: 'tsNameLike',
    },
    // 适配后端 保留字段2 搜索 reserved1
    {
      label: '保留字段2',
      value: 'reserved1',
      componentType: 'input',
      event: productSearch,
      hidden: true,
      show: true,
    },
    {
      componentType: 'input',
      event: supplierSearch,
      hidden: true,
      label: '社会信用代码',
      show: true,
      value: 'tsUniformSocialCreditCodeLike',
    },
    {
      componentType: 'select-model',
      label: '数据来源',
      value: 'dataSourceMult',
      code: 'data_source',
      multiple: true,
      event: supplierSearch,
    },
    {
      label: '是否对照',
      value: 'isCompare',
      componentType: 'select-model',
      code: 'yes_or_no',
      event: supplierSearch,
      show: true,
      hidden: true,
    },
  ],
  searchBtn: [
    { type: 'button', label: '搜索', event: supplierSearch },
    { type: 'button', label: '重置', event: supplierClearSearch },
  ],
  btnList: [
    {
      type: 'button',
      label: '新增',
      event: openSupplierDialog,
      show: proxy.$permission('informationSyncManage:supplierAdd'),
    },
    {
      value: 'supplierRemove',
      label: '删除',
      type: 'slot',
      show: proxy.$permission('informationSyncManage:supplierDel'),
    },
    {
      type: 'slot',
      value: 'supplierImport',
      show: proxy.$permission('informationSyncManage:supplierImport'),
    },
    {
      type: 'slot',
      value: 'supplierUpload',
      show: proxy.$permission('informationSyncManage:supplierUpload'),
    },
    {
      type: 'button',
      label: '拉取最新数据',
      event: getSupplierNewList,
      show: proxy.$permission('informationSyncManage:supplierPullData'),
    },
  ],
})
const supplierTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: undefined,
  data: [],
  selections: [],
  fieldList: [
    { label: '编码', value: 'tsCode' },
    { label: '名称', value: 'tsName' },
    { label: '社会信用代码', value: 'tsUniformSocialCreditCode' },
    { label: '保留1', value: 'reserved1' },
    { label: '保留2', value: 'reserved2' },
    { label: '保留3', value: 'reserved3' },
    { label: '保留4', value: 'reserved4' },
    { label: '保留5', value: 'reserved5' },
    { label: '数据来源', value: 'dataSourceValue' },
    { label: '是否对照', value: 'isCompareValue' },
    { label: '最新对照时间', value: 'compareTime' },
    { label: '创建人', value: 'createUserName' },
    { label: '创建时间', value: 'createTime' },
  ],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '90',
    btList: [
      {
        label: '删除',
        event: supplierRemove,
        popconfirmText: '删除后将改变数据,是否继续？',
        show: proxy.$permission('informationSyncManage:supplierDel'),
      },
      {
        label: '修改',
        event: supplierUpdate,
        show: proxy.$permission('informationSyncManage:supplierUpdate'),
        ifRender: function (row) {
          return row.dataSource !== 3
        },
      },
    ],
  },
})
//仓库信息
const depotFilterInfo = ref({
  clearType: true,
  query: {
    sort: 'create_time desc',
  },
  searchList: [
    {
      componentType: 'input',
      event: depotSearch,
      hidden: true,
      label: '编码',
      show: true,
      value: 'tsCodeLike',
    },
    {
      componentType: 'input',
      event: depotSearch,
      hidden: true,
      label: '名称',
      show: true,
      value: 'tsNameLike',
    },
    {
      componentType: 'select-model',
      label: '数据来源',
      value: 'dataSourceMult',
      code: 'data_source',
      multiple: true,
      event: depotSearch,
    },
    {
      label: '是否对照',
      value: 'isCompare',
      componentType: 'select-model',
      code: 'yes_or_no',
      event: depotSearch,
      show: true,
      hidden: true,
    },
  ],
  searchBtn: [
    { type: 'button', label: '搜索', event: depotSearch },
    { type: 'button', label: '重置', event: depotClearSearch },
  ],
  btnList: [
    {
      type: 'button',
      label: '新增',
      event: openDepotDialog,
      show: proxy.$permission('informationSyncManage:depotAdd'),
    },
    {
      value: 'depotRemove',
      label: '删除',
      type: 'slot',
      show: proxy.$permission('informationSyncManage:depotDel'),
    },
    {
      type: 'slot',
      value: 'depotImport',
      show: proxy.$permission('informationSyncManage:depotImport'),
    },
    {
      type: 'slot',
      value: 'depotUpload',
      show: proxy.$permission('informationSyncManage:depotUpload'),
    },
    {
      type: 'button',
      label: '拉取最新数据',
      event: getDepotNewList,
      show: proxy.$permission('informationSyncManage:depotPullData'),
    },
  ],
})
const depotTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: undefined,
  data: [],
  selections: [],
  fieldList: [
    { label: '编码', value: 'tsCode' },
    { label: '名称', value: 'tsName' },
    { label: '保留1', value: 'reserved1' },
    { label: '保留2', value: 'reserved2' },
    { label: '保留3', value: 'reserved3' },
    { label: '保留4', value: 'reserved4' },
    { label: '保留5', value: 'reserved5' },
    { label: '数据来源', value: 'dataSourceValue' },
    { label: '是否对照', value: 'isCompareValue' },
    { label: '最新对照时间', value: 'compareTime' },
    { label: '创建人', value: 'createUserName' },
    { label: '创建时间', value: 'createTime' },
  ],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '90',
    btList: [
      {
        label: '删除',
        event: depotRemove,
        popconfirmText: '删除后将改变数据,是否继续？',
        show: proxy.$permission('informationSyncManage:depotDel'),
      },
      {
        label: '修改',
        event: depotUpdate,
        show: proxy.$permission('informationSyncManage:depotUpdate'),
        ifRender: function (row) {
          return row.dataSource !== 3
        },
      },
    ],
  },
})

//项目信息
const projectFilterInfo = ref({
  clearType: true,
  query: {
    sort: 'create_time desc',
  },
  searchList: [
    {
      componentType: 'input',
      event: projectSearch,
      hidden: true,
      label: '项目编码',
      show: true,
      value: 'tsProjectCodeLike',
    },
    {
      componentType: 'input',
      event: projectSearch,
      hidden: true,
      label: '项目名称',
      show: true,
      value: 'tsProjectNameLike',
    },
    {
      componentType: 'select-model',
      label: '数据来源',
      value: 'dataSourceMult',
      code: 'data_source',
      multiple: true,
      event: projectSearch,
    },
    {
      label: '是否对照',
      value: 'isCompare',
      componentType: 'select-model',
      code: 'yes_or_no',
      event: projectSearch,
      show: true,
      hidden: true,
    },
  ],
  searchBtn: [
    { type: 'button', label: '搜索', event: projectSearch },
    { type: 'button', label: '重置', event: projectClearSearch },
  ],
  btnList: [
    {
      type: 'button',
      label: '新增',
      event: openProjectDialog,
      show: proxy.$permission('informationSyncManage:projectAdd'),
    },
    {
      value: 'projectRemove',
      label: '删除',
      type: 'slot',
      show: proxy.$permission('informationSyncManage:projectDel'),
    },
    {
      type: 'slot',
      value: 'projectImport',
      show: proxy.$permission('informationSyncManage:projectImport'),
    },
    {
      type: 'slot',
      value: 'projectUpload',
      show: proxy.$permission('informationSyncManage:projectUpload'),
    },
    {
      type: 'button',
      label: '拉取最新数据',
      event: getProjectNewList,
      show: proxy.$permission('informationSyncManage:projectPullData'),
    },
  ],
})
const projectTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: undefined,
  data: [],
  selections: [],
  fieldList: [
    { label: '项目编码', value: 'tsProjectCode' },
    { label: '项目名称', value: 'tsProjectName' },
    { label: '单价', value: 'tsPrice' },
    { label: '保留1', value: 'reserved1' },
    { label: '保留2', value: 'reserved2' },
    { label: '保留3', value: 'reserved3' },
    { label: '保留4', value: 'reserved4' },
    { label: '保留5', value: 'reserved5' },
    { label: '数据来源', value: 'dataSourceValue' },
    { label: '是否对照', value: 'isCompareValue' },
    { label: '最新对照时间', value: 'compareTime' },
    { label: '创建人', value: 'createUserName' },
    { label: '创建时间', value: 'createTime' },
  ],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '90',
    btList: [
      {
        label: '删除',
        event: projectRemove,
        popconfirmText: '删除后将改变数据,是否继续？',
        show: proxy.$permission('informationSyncManage:projectDel'),
      },
      {
        label: '修改',
        event: projectUpdate,
        show: proxy.$permission('informationSyncManage:projectUpdate'),
        ifRender: function (row) {
          return row.dataSource !== 3
        },
      },
    ],
  },
})
userTableInfo.value.api = getTripartiteSystemUserPage
deptTableInfo.value.api = getTripartiteSystemDeptPage
productTableInfo.value.api = getTripartiteSystemProductPage
supplierTableInfo.value.api = getTripartiteSystemSupplierPage
assetTableInfo.value.api = getTripartiteSystemDevicePage
projectTableInfo.value.api = getTripartiteSystemProjectPage
depotTableInfo.value.api = getTripartiteSystemDepotPage


watch(
  ()=>formInfo.value.data.tsSystemCode,
  (value) => {
    console.log(value)
    productFilterInfo.value.query.reserved2 = ''
    supplierFilterInfo.value.query.reserved2 = ''
    productFilterInfo.value.searchList.find((item) => {
      if(item.value === 'reserved2') {
          if(value === 'SC_PLATFORM') {
            item.componentType = 'select-model'
            item.code = 'network_product_type'
          } else {
            item.componentType = 'input'
            item.code = ''
          }
        }
      })
    supplierFilterInfo.value.searchList.find((item) => {
      if(item.value === 'reserved1') {
        if(value === 'SC_PLATFORM') {
            item.componentType = 'select-model'
            item.code = 'network_product_type'
          } else {
            item.componentType = 'input'
            item.code = ''
          }
        }
      })
  }
)


getProductList()
// getUserList()
function downloadTemplate(type) {
  exportTemplateExcel(type).then((res) => {
    if (res) {
      proxy.$fn.parseExcel(res)
    }
  })
}
function getProductList() {
  productFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  console.log(productFilterInfo.value.query, 'productFilterInfo.value.query')
  productTableInfo.value.refresh = Math.random()
}
function getProductNewList() {
  getTripartiteSystemProductPullData(formInfo.value.data).then((res) => {
    if (res && res.success) {
      productSearch()
    }
  })
}
function productSearch() {
  productFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  productTableInfo.value.initCurpage = Math.random()
  productTableInfo.value.refresh = Math.random()
}
function productClearSearch() {
  productFilterInfo.value.clearType = !productFilterInfo.value.clearType
  productFilterInfo.value.query = { sort: 'create_time desc' }
  productSearch()
}
//
function getAssetList() {
  assetFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  assetTableInfo.value.refresh = Math.random()
}
function getAssetNewList() {
  getTripartiteSystemDevicePullData(formInfo.value.data).then((res) => {
    if (res && res.success) {
      assetSearch()
    }
  })
}
function assetSearch() {
  assetFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  assetTableInfo.value.initCurpage = Math.random()
  assetTableInfo.value.refresh = Math.random()
}
function assetClearSearch() {
  assetFilterInfo.value.clearType = !assetFilterInfo.value.clearType
  assetFilterInfo.value.query = { sort: 'create_time desc' }
  assetSearch()
}
function assetRemove(row = undefined) {
  if (row && row.id) {
    let ids = [row.id]
    deleteTripartiteSystemDevice(ids).then((res) => {
      if (res && res.success) {
        getAssetList()
      }
    })
  } else {
    let ids = assetTableInfo.value.selections.map((item) => item.id)
    proxy
      .$confirm('删除后将改变数据,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then(() => {
        deleteTripartiteSystemDevice(ids).then((res) => {
          if (res && res.success) {
            getAssetList()
          }
        })
      })
  }
}
function assetUpdate(row) {
  //修改
  dialogInfo.value.formInfo.data = { ...row }
  dialogInfo.value.type = 'asset'
  dialogInfo.value.formInfo.assetFieldList.forEach((item) => {
    if (item.value === 'tsCode') {
      if (row.isCompare == 1) {
        item.disabled = true
      } else {
        item.disabled = false
      }
    }
  })
  dialogInfo.value.visible = true
}
function openAssetDialog() {
  //新增
  dialogInfo.value.type = 'asset'
  dialogInfo.value.formInfo.assetFieldList.forEach((item) => {
    if (item.value === 'tsCode') {
      item.disabled = false
    }
  })
  dialogInfo.value.formInfo.data = {}
  dialogInfo.value.visible = true
}
//
function getDepotList() {
  depotFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  depotTableInfo.value.refresh = Math.random()
}
function getDepotNewList() {
  getTripartiteSystemDepotPullData(formInfo.value.data).then((res) => {
    if (res && res.success) {
      depotSearch()
    }
  })
}
function depotSearch() {
  depotFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  depotTableInfo.value.initCurpage = Math.random()
  depotTableInfo.value.refresh = Math.random()
}
function depotClearSearch() {
  depotFilterInfo.value.clearType = !depotFilterInfo.value.clearType
  depotFilterInfo.value.query = { sort: 'create_time desc' }
  depotSearch()
}
function depotRemove(row = undefined) {
  if (row && row.id) {
    let ids = [row.id]
    deleteTripartiteSystemDepot(ids).then((res) => {
      if (res && res.success) {
        getDepotList()
      }
    })
  } else {
    let ids = depotTableInfo.value.selections.map((item) => item.id)
    proxy
      .$confirm('删除后将改变数据,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then(() => {
        deleteTripartiteSystemDepot(ids).then((res) => {
          if (res && res.success) {
            getDepotList()
          }
        })
      })
  }
}
function depotUpdate(row) {
  //修改
  dialogInfo.value.formInfo.data = { ...row }
  dialogInfo.value.type = 'depot'
  dialogInfo.value.formInfo.depotFieldList.forEach((item) => {
    if (item.value === 'tsCode') {
      if (row.isCompare == 1) {
        item.disabled = true
      } else {
        item.disabled = false
      }
    }
  })
  dialogInfo.value.visible = true
}
function openDepotDialog() {
  //新增
  dialogInfo.value.type = 'depot'
  dialogInfo.value.formInfo.depotFieldList.forEach((item) => {
    if (item.value === 'tsCode') {
      item.disabled = false
    }
  })
  dialogInfo.value.formInfo.data = {}
  dialogInfo.value.visible = true
}
//
function getProjectList() {
  projectFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  projectTableInfo.value.refresh = Math.random()
}
function getProjectNewList() {
  getTripartiteSystemProjectPullData(formInfo.value.data).then((res) => {
    if (res && res.success) {
      projectSearch()
    }
  })
}
function projectSearch() {
  projectFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  projectTableInfo.value.initCurpage = Math.random()
  projectTableInfo.value.refresh = Math.random()
}
function projectClearSearch() {
  projectFilterInfo.value.clearType = !projectFilterInfo.value.clearType
  projectFilterInfo.value.query = { sort: 'create_time desc' }
  projectSearch()
}
function projectRemove(row = undefined) {
  if (row && row.id) {
    let ids = [row.id]
    deleteTripartiteSystemProject(ids).then((res) => {
      if (res && res.success) {
        getProjectList()
      }
    })
  } else {
    let ids = projectTableInfo.value.selections.map((item) => item.id)
    proxy
      .$confirm('删除后将改变数据,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then(() => {
        deleteTripartiteSystemProject(ids).then((res) => {
          if (res && res.success) {
            getProjectList()
          }
        })
      })
  }
}
function projectUpdate(row) {
  //修改
  dialogInfo.value.formInfo.data = { ...row }
  dialogInfo.value.type = 'project'
  dialogInfo.value.formInfo.projectFieldList.forEach((item) => {
    if (item.value === 'tsProjectCode') {
      if (row.isCompare == 1) {
        item.disabled = true
      } else {
        item.disabled = false
      }
    }
  })
  dialogInfo.value.visible = true
}
function openProjectDialog() {
  //新增
  dialogInfo.value.type = 'project'
  dialogInfo.value.formInfo.projectFieldList.forEach((item) => {
    if (item.value === 'tsProjectCode') {
      item.disabled = false
    }
  })
  dialogInfo.value.formInfo.data = {}
  dialogInfo.value.visible = true
}
function dialogClose() {
  //关闭弹窗
  dialogInfo.value.visible = false
  dialogInfo.value.formInfo.data = {}
}
function dialogSave() {
  //弹窗保存
  let params = {
    ...dialogInfo.value.formInfo.data,
    tsSystemCode: formInfo.value.data.tsSystemCode,
  }
  if (dialogInfo.value.type === 'product') {
    //物资
    dialogInfo.value.formInfo.ref.validate((vaild) => {
      if (vaild) {
        let api = params.id
          ? updateTripartiteSystemProduct
          : saveTripartiteSystemProduct
        api(params).then((res) => {
          if (res && res.success) {
            dialogClose()
            getProductList()
          }
        })
      }
    })
  } else if (dialogInfo.value.type === 'asset') {
    //设备
    dialogInfo.value.formInfo.ref.validate((vaild) => {
      if (vaild) {
        let api = params.id
          ? updateTripartiteSystemDevice
          : saveTripartiteSystemDevice
        api(params).then((res) => {
          if (res && res.success) {
            dialogClose()
            getAssetList()
          }
        })
      }
    })
  } else if (dialogInfo.value.type === 'supplier') {
    //供应商
    dialogInfo.value.formInfo.ref.validate((vaild) => {
      if (vaild) {
        let api = params.id
          ? updateTripartiteSystemSupplier
          : saveTripartiteSystemSupplier
        api(params).then((res) => {
          if (res && res.success) {
            dialogClose()
            getSupplierList()
          }
        })
      }
    })
  } else if (dialogInfo.value.type === 'depot') {
    //仓库
    dialogInfo.value.formInfo.ref.validate((vaild) => {
      if (vaild) {
        let api = params.id
          ? updateTripartiteSystemDepot
          : saveTripartiteSystemDepot
        api(params).then((res) => {
          if (res && res.success) {
            dialogClose()
            getDepotList()
          }
        })
      }
    })
  } else if (dialogInfo.value.type === 'project') {
    //项目
    dialogInfo.value.formInfo.ref.validate((vaild) => {
      if (vaild) {
        let api = params.id
          ? updateTripartiteSystemProject
          : saveTripartiteSystemProject
        api(params).then((res) => {
          if (res && res.success) {
            dialogClose()
            getProjectList()
          }
        })
      }
    })
  }
}
function productRemove(row = undefined) {
  if (row && row.id) {
    let ids = [row.id]
    deleteTripartiteSystemProduct(ids).then((res) => {
      if (res && res.success) {
        getProductList()
      }
    })
  } else {
    let ids = productTableInfo.value.selections.map((item) => item.id)
    proxy
      .$confirm('删除后将改变数据,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then(() => {
        deleteTripartiteSystemProduct(ids).then((res) => {
          if (res && res.success) {
            getProductList()
          }
        })
      })
  }
}
function productUpdate(row) {
  //修改
  dialogInfo.value.formInfo.data = { ...row }
  dialogInfo.value.type = 'product'
  dialogInfo.value.formInfo.productFieldList.forEach((item) => {
    if (item.value === 'tsProductCode') {
      if (row.isCompare == 1) {
        item.disabled = true
      } else {
        item.disabled = false
      }
    }
  })
  dialogInfo.value.visible = true
}
function openProductDialog() {
  //新增
  dialogInfo.value.type = 'product'
  dialogInfo.value.formInfo.productFieldList.forEach((item) => {
    if (item.value === 'tsProductCode') {
      item.disabled = false
    }
  })
  dialogInfo.value.formInfo.data = {}
  dialogInfo.value.visible = true
}

function getSupplierList() {
  supplierFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  supplierTableInfo.value.refresh = Math.random()
}
function getSupplierNewList() {
  getTripartiteSystemSupplierPullData(formInfo.value.data).then((res) => {
    if (res && res.success) {
      supplierSearch()
    }
  })
}
function supplierSearch() {
  supplierFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  supplierTableInfo.value.initCurpage = Math.random()
  supplierTableInfo.value.refresh = Math.random()
}
function supplierClearSearch() {
  supplierFilterInfo.value.clearType = !supplierFilterInfo.value.clearType
  supplierFilterInfo.value.query = { sort: 'create_time desc' }
  supplierSearch()
}
function supplierRemove(row = undefined) {
  if (row && row.id) {
    let ids = [row.id]
    deleteTripartiteSystemSupplier(ids).then((res) => {
      if (res && res.success) {
        getSupplierList()
      }
    })
  } else {
    let ids = supplierTableInfo.value.selections.map((item) => item.id)
    proxy
      .$confirm('删除后将改变数据,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then(() => {
        deleteTripartiteSystemSupplier(ids).then((res) => {
          if (res && res.success) {
            getSupplierList()
          }
        })
      })
  }
}
function supplierUpdate(row) {
  //修改
  dialogInfo.value.formInfo.data = { ...row }
  dialogInfo.value.type = 'supplier'
  dialogInfo.value.formInfo.supplierFieldList.forEach((item) => {
    if (item.value === 'tsCode') {
      if (row.isCompare == 1) {
        item.disabled = true
      } else {
        item.disabled = false
      }
    }
  })
  dialogInfo.value.visible = true
}
function openSupplierDialog() {
  //新增
  dialogInfo.value.type = 'supplier'
  dialogInfo.value.formInfo.supplierFieldList.forEach((item) => {
    if (item.value === 'tsCode') {
      item.disabled = false
    }
  })
  dialogInfo.value.formInfo.data = {}
  dialogInfo.value.visible = true
}
function changClient() {
  if (activeName.value == '1') {
    productTableInfo.value.api = getTripartiteSystemProductPage
    getProductList()
  } else if (activeName.value == '2') {
    assetTableInfo.value.api = getTripartiteSystemDevicePage
    getAssetList()
  } else if (activeName.value == '3') {
    supplierTableInfo.value.api = getTripartiteSystemSupplierPage
    getSupplierList()
  } else if (activeName.value == '4') {
    userTableInfo.value.api = getTripartiteSystemUserPage
    getUserList()
  } else if (activeName.value == '5') {
    deptTableInfo.value.api = getTripartiteSystemDeptPage
    getDeptList()
  } else if (activeName.value == '6') {
    depotTableInfo.value.api = getTripartiteSystemDepotPage
    getDepotList()
  } else if (activeName.value == '7') {
    projectTableInfo.value.api = getTripartiteSystemProjectPage
    getProjectList()
  }
}
function handleClick(tab) {
  if (tab == '1') {
    productTableInfo.value.data = []
    productTableInfo.value.api = getTripartiteSystemProductPage
    getProductList()
  } else if (tab == '2') {
    assetTableInfo.value.data = []
    assetTableInfo.value.api = getTripartiteSystemDevicePage
    getAssetList()
  } else if (tab == '3') {
    supplierTableInfo.value.data = []
    supplierTableInfo.value.api = getTripartiteSystemSupplierPage
    getSupplierList()
  } else if (tab == '4') {
    userTableInfo.value.data = []
    userTableInfo.value.api = getTripartiteSystemUserPage
    getUserList()
  } else if (tab == '5') {
    deptTableInfo.value.data = []
    deptTableInfo.value.api = getTripartiteSystemDeptPage
    getDeptList()
  } else if (tab == '6') {
    depotTableInfo.value.data = []
    depotTableInfo.value.api = getTripartiteSystemDepotPage
    getDepotList()
  } else if (tab == '7') {
    projectTableInfo.value.data = []
    projectTableInfo.value.api = getTripartiteSystemProjectPage
    getProjectList()
  }
}
function getUserList() {
  userFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  userTableInfo.value.refresh = Math.random()
}
function userSearch() {
  userFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  userTableInfo.value.initCurpage = Math.random()
  userTableInfo.value.refresh = Math.random()
}
function userClearSearch() {
  userFilterInfo.value.clearType = !userFilterInfo.value.clearType
  userFilterInfo.value.query = { sort: 'create_time desc' }
}
function userCreate() {
  userDialogInfo.value.visible = true
}
function getUserNewList() {
  getTripartiteSystemUserPullData(formInfo.value.data).then((res) => {
    if (res && res.success) {
      userSearch()
    }
  })
}
function userRemove(row) {
  if (row && row.id) {
    let ids = [row.id]
    reUserRemove(ids)
  } else {
    let ids = userTableInfo.value.selections.map((item) => item.id)
    proxy
      .$confirm('删除后将改变数据,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then(() => {
        reUserRemove(ids)
      })
  }
}
function reUserRemove(ids) {
  deleteTripartiteSystemUser(ids).then((res) => {
    if (res && res.success) {
      getUserList()
    }
  })
}
function userUpdate(row) {
  getTripartiteSystemUserById(row.id).then((res) => {
    if (res && res.success) {
      userFormInfo.value.data = res.data
      userDialogInfo.value.visible = true
      userFormInfo.value.fieldList.forEach((item) => {
        if (item.value === 'tsUserName' && res.data.isCompare == 1) {
          item.disabled = true
        }
      })
    }
  })
}
function handleUserClose() {
  userFormInfo.value.data = {}
  userDialogInfo.value.visible = false
  userFormInfo.value.fieldList.forEach((item) => {
    if (item.value === 'tsUserName') {
      item.disabled = false
    }
  })
}
function checkUserConfirm() {
  userFormInfo.value.ref.validate((valid) => {
    if (valid) {
      let api = userFormInfo.value.data.id
        ? updateTripartiteSystemUser
        : createdTripartiteSystemUser
      let params = {
        ...userFormInfo.value.data,
        tsSystemCode: formInfo.value.data.tsSystemCode,
      }
      api(params).then((res) => {
        if (res && res.success) {
          handleUserClose()
          getUserList()
        }
      })
    }
  })
}
function handleUserEvent(event, data) {
  switch (event) {
    case 'tableCheck':
      userTableInfo.value.selections = [...data]
      break
  }
}
function handleDepotEvent(event, data) {
  switch (event) {
    case 'tableCheck':
      depotTableInfo.value.selections = [...data]
      break
  }
}
function handleProductEvent(event, data) {
  switch (event) {
    case 'list':
      productTableInfo.value.data = data.map((item) => {
        if (item.dataSource == 3) {
          item.reserved2 = item.reserved2Value || item.reserved2
        }
        return item
      })
      break

    case 'tableCheck':
      productTableInfo.value.selections = [...data]
      break
  }
}
function handleAssetEvent(event, data) {
  switch (event) {
    case 'tableCheck':
      assetTableInfo.value.selections = [...data]
      break
  }
}
function handleProjectEvent(event, data) {
  switch (event) {
    case 'tableCheck':
      projectTableInfo.value.selections = [...data]
      break
  }
}
function handleSupplierEvent(event, data) {
  switch (event) {
    case 'tableCheck':
      supplierTableInfo.value.selections = [...data]
      break
  }
}
function userImportOrders(resp) {
  //导入
  userUploadInfo.value.loading.close()
  if (resp && resp.success) {
    proxy.$message.success({
      duration: 3500,
      showClose: true,
      message: resp.msg,
    })
    getUserList()
  } else {
    proxy.$message.error({
      message: resp.msg,
      duration: 3000,
      showClose: true,
    })
  }
}
function userUploadError(err) {
  if (err) {
    proxy.$message.error({
      message: '系统错误',
      duration: 3000,
      showClose: true,
    })
  }
  userUploadInfo.value.loading.close()
}
function userBeforeUpload() {
  //导入
  //发生请求时打开加载动画
  userUploadInfo.value.loading = ElLoading.service({
    fullscreen: true,
    background: 'rgba(255,255,255,.4)',
  })
  return true
}
function productImportOrders(resp) {
  //导入
  productUploadInfo.value.loading.close()
  if (resp && resp.success) {
    proxy.$message.success({
      duration: 3500,
      showClose: true,
      message: resp.msg,
    })
    getProductList()
  } else {
    proxy.$message.error({
      message: resp.msg,
      duration: 3000,
      showClose: true,
    })
  }
}
function productUploadError(err) {
  if (err) {
    proxy.$message.error({
      message: '系统错误',
      duration: 3000,
      showClose: true,
    })
  }
  productUploadInfo.value.loading.close()
}
function productBeforeUpload() {
  //导入
  //发生请求时打开加载动画
  productUploadInfo.value.loading = ElLoading.service({
    fullscreen: true,
    background: 'rgba(255,255,255,.4)',
  })
  return true
}

function supplierImportOrders(resp) {
  //导入
  supplierUploadInfo.value.loading.close()
  if (resp && resp.success) {
    proxy.$message.success({
      duration: 3500,
      showClose: true,
      message: resp.msg,
    })
    getSupplierList()
  } else {
    proxy.$message.error({
      message: resp.msg,
      duration: 3000,
      showClose: true,
    })
  }
}
function supplierUploadError(err) {
  if (err) {
    proxy.$message.error({
      message: '系统错误',
      duration: 3000,
      showClose: true,
    })
  }
  supplierUploadInfo.value.loading.close()
}
function supplierBeforeUpload() {
  //导入
  //发生请求时打开加载动画
  supplierUploadInfo.value.loading = ElLoading.service({
    fullscreen: true,
    background: 'rgba(255,255,255,.4)',
  })
  return true
}
function getDeptList() {
  deptFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  deptTableInfo.value.refresh = Math.random()
}
function deptSearch() {
  deptFilterInfo.value.query.tsSystemCode = formInfo.value.data.tsSystemCode
  deptTableInfo.value.initCurpage = Math.random()
  deptTableInfo.value.refresh = Math.random()
}
function deptClearSearch() {
  deptFilterInfo.value.clearType = !deptFilterInfo.value.clearType
  deptFilterInfo.value.query = { sort: 'create_time desc' }
}
function handleDeptClose() {
  deptFormInfo.value.data = {}
  deptDialogInfo.value.visible = false
  deptFormInfo.value.fieldList.forEach((item) => {
    if (item.value === 'tsCode') {
      item.disabled = false
    }
  })
}
function checkDeptConfirm() {
  deptFormInfo.value.ref.validate((valid) => {
    if (valid) {
      let api = deptFormInfo.value.data.id
        ? updateTripartiteSystemDept
        : createdTripartiteSystemDept
      let params = {
        ...deptFormInfo.value.data,
        tsSystemCode: formInfo.value.data.tsSystemCode,
      }
      api(params).then((res) => {
        if (res && res.success) {
          handleDeptClose()
          getDeptList()
        }
      })
    }
  })
}
function deptCreate() {
  deptDialogInfo.value.visible = true
}
function getDeptNewList() {
  getTripartiteSystemDeptPullData(formInfo.value.data).then((res) => {
    if (res && res.success) {
      deptSearch()
    }
  })
}
function deptUpdate(row) {
  getTripartiteSystemDeptById(row.id).then((res) => {
    if (res && res.success) {
      deptFormInfo.value.data = res.data
      deptDialogInfo.value.visible = true
      deptFormInfo.value.fieldList.forEach((item) => {
        if (item.value === 'tsCode' && res.data.isCompare == 1) {
          item.disabled = true
        }
      })
    }
  })
}
function deptRemove(row) {
  if (row && row.id) {
    let ids = [row.id]
    reDeptRemove(ids)
  } else {
    let ids = deptTableInfo.value.selections.map((item) => item.id)
    proxy
      .$confirm('删除后将改变数据,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then(() => {
        reDeptRemove(ids)
      })
  }
}
function reDeptRemove(ids) {
  deleteTripartiteSystemDept(ids).then((res) => {
    if (res && res.success) {
      getDeptList()
    }
  })
}
function handleDeptEvent(event, data) {
  switch (event) {
    case 'tableCheck':
      deptTableInfo.value.selections = [...data]
      break
  }
}
function deptImportOrders(resp) {
  //导入
  deptUploadInfo.value.loading.close()
  if (resp && resp.success) {
    proxy.$message.success({
      duration: 3500,
      showClose: true,
      message: resp.msg,
    })
    getDeptList()
  } else {
    proxy.$message.error({
      message: resp.msg,
      duration: 3000,
      showClose: true,
    })
  }
}
function deptUploadError(err) {
  if (err) {
    proxy.$message.error({
      message: '系统错误',
      duration: 3000,
      showClose: true,
    })
  }
  deptUploadInfo.value.loading.close()
}
function deptBeforeUpload() {
  //导入
  //发生请求时打开加载动画
  deptUploadInfo.value.loading = ElLoading.service({
    fullscreen: true,
    background: 'rgba(255,255,255,.4)',
  })
  return true
}
function assetImportOrders(resp) {
  //导入
  assetUploadInfo.value.loading.close()
  if (resp && resp.success) {
    proxy.$message.success({
      duration: 3500,
      showClose: true,
      message: resp.msg,
    })
    getAssetList()
  } else {
    proxy.$message.error({
      message: resp.msg,
      duration: 3000,
      showClose: true,
    })
  }
}
function assetUploadError(err) {
  if (err) {
    proxy.$message.error({
      message: '系统错误',
      duration: 3000,
      showClose: true,
    })
  }
  assetUploadInfo.value.loading.close()
}
function assetBeforeUpload() {
  //导入
  //发生请求时打开加载动画
  assetUploadInfo.value.loading = ElLoading.service({
    fullscreen: true,
    background: 'rgba(255,255,255,.4)',
  })
  return true
}
function projectImportOrders(resp) {
  //导入
  projectUploadInfo.value.loading.close()
  if (resp && resp.success) {
    proxy.$message.success({
      duration: 3500,
      showClose: true,
      message: resp.msg,
    })
    getProjectList()
  } else {
    proxy.$message.error({
      message: resp.msg,
      duration: 3000,
      showClose: true,
    })
  }
}
function projectUploadError(err) {
  if (err) {
    proxy.$message.error({
      message: '系统错误',
      duration: 3000,
      showClose: true,
    })
  }
  projectUploadInfo.value.loading.close()
}
function projectBeforeUpload() {
  //导入
  //发生请求时打开加载动画
  projectUploadInfo.value.loading = ElLoading.service({
    fullscreen: true,
    background: 'rgba(255,255,255,.4)',
  })
  return true
}
function depotImportOrders(resp) {
  //导入
  depotUploadInfo.value.loading.close()
  if (resp && resp.success) {
    proxy.$message.success({
      duration: 3500,
      showClose: true,
      message: resp.msg,
    })
    getDepotList()
  } else {
    proxy.$message.error({
      message: resp.msg,
      duration: 3000,
      showClose: true,
    })
  }
}
function depotUploadError(err) {
  if (err) {
    proxy.$message.error({
      message: '系统错误',
      duration: 3000,
      showClose: true,
    })
  }
  depotUploadInfo.value.loading.close()
}
function depotBeforeUpload() {
  //导入
  //发生请求时打开加载动画
  depotUploadInfo.value.loading = ElLoading.service({
    fullscreen: true,
    background: 'rgba(255,255,255,.4)',
  })
  return true
}
</script>

<style scoped lang="scss">
.app-container {
  height: calc(100vh - 79px);
}
:deep(.box-scroll-y) {
  height: calc(100%) !important;
}
</style>
